/// <reference path="../typings/index.d.ts" />
/// <reference path="../src/locationService.ts" />
/// <reference path="../src/tms.ts" />

describe('getLocationList',() => {
    var injector:ng.auto.IInjectorService;
    var service:ILocationService;

    beforeEach(() => {
        injector = angular.injector(['ng','tms']);
        service = injector.get<ILocationService>('locationService');
    });

    //获取定位开通状态
    it('get locationState',(done) => {
        service.getLocationState('1',true).then((res) => {
            expect(res.data.statusCode).toBe("2");
            expect(res.data.dateTime).toBe("2016/8/30 9:00");
            expect(res.data.messageInfo).toBe("2");
            expect(res.data.phoneNumber).toBe("183");
            expect(res.data.isRegister).toBe(false);
            // expect(res.data.extData).toBe("1|true");
            done();
        },(err) => {
            done.fail(err);
        });
    });

    //获取定位开通
    it('get Dredge',(done) => {
        service.getDredge('2',true).then((res) => {
            expect(res.data.messageInfo).toBe("22");
            expect(res.data.phoneNumber).toBe("133");
            expect(res.data.statusCode).toBe("3");
            expect(res.data.isRegister).toBe(false);
            // expect(res.data.extData).toBe("2|true");
            done();
        },(err) => {
            done.fail(err);
        });
    });


    //获取定位信息
    it('get location',(done) => {
        service.getLocation('3',true).then((res) => {
            expect(res.data.vehicleId).toBe("1");
            expect(res.data.userId).toBe("2");
            expect(res.data.creationTime).toBe("2016/9/6 15:00");
            expect(res.data.area).toBe("江苏");
            expect(res.data.longitude).toBe("80");
            expect(res.data.latitude).toBe("70");
            expect(res.data.locationType).toBe("省");
            expect(res.data.isRegister).toBe(false);
            // expect(res.data.extData).toBe("3|true");
            done();
        },(err) => {
            done.fail(err);
        });
    });


    //获取为车辆定位的历史定位信息
    it('get historyLocation',(done) => {
        service.getHistoryLocation('4',true).then((res) => {
            expect(res.data.vehicleId).toBe("3");
            expect(res.data.userId).toBe("3");
            expect(res.data.creationTime).toBe("2016/9/5 8:00");
            expect(res.data.area).toBe("镇江");
            expect(res.data.longitude).toBe("90");
            expect(res.data.latitude).toBe("50");
            expect(res.data.locationType).toBe("市");
            expect(res.data.isRegister).toBe(false);
            done();
        },(err) => {
            done.fail(err);
        });
    });
    
});